<%--
  Created by IntelliJ IDEA.
  User: xumengdi
  Date: 2018/4/20
  Time: 15:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
    <title>布控</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ? MYOA_CHARSET : htmlspecialchars($HTML_PAGE_CHARSET))?>" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/css/street/street.css"/>
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <%--<link rel="stylesheet" type="text/css" href="/css/patrol/patrol.css"/>--%>
    <link rel="stylesheet" href="/css/base.css">
    <script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layer/layer.js?20201106" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/tablePage.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <style>
        body{
            margin:0px;
        }
        .info{
            width:180px;
            height:28px;
            border-radius: 3px;
            margin-left:20px;
            vertical-align: middle;
        }
        button{
            background: #2f8ae3;
            margin-left: 2%;
            padding: 5px 10px;
            border-radius: 4px;
            color: #fff;
            cursor: pointer;
            font-size:14px;
        }
        #add{
            float:right;
            margin:0px 20px 8px 0px;
        }
        .table{
            width:96%;
            margin:5px auto 0px;
        }
        .tableFoot{
            margin-top:20px;
        }
        .childCheck{
            width:16px;
            vertical-align: middle;
        }
        #checkAll{
            margin-left:10px;
        }
        /*#outport{
            background: #cc0000;
        }*/
        #inportEdit{
            background: #009900;
        }
        .M-box3 .active{
            margin: 0px 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color:#fff;
            text-align:center;
            display: inline-block;
        }
        .M-box3 a{
            margin: 0 3px;
            width: 29px;
            height: 29px;
            line-height: 29px;
            font-size: 12px;
            display: inline-block;
            text-align:center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #bdbdbd;
            text-decoration: none;
        }
        .mainBg .mainTitle{
            min-width: 750px;
        }
        .mainTitleUl .bordercolor span{
            font-size:14px;
        }
        .mainTitleUl .bordercolor label input[type=text]{
            font-size:14px;
        }
        .mainBg{
            padding-top:0px;
        }
        #grid{
            background: none!important;
        }
        #add{
            position: static!important;
            margin-bottom:10px!important;
        }
        .wid{
            width:150px;
            margin:0 auto;
            overflow: hidden;
            white-space:nowrap;
            text-overflow:ellipsis;
        }
        #queryGridId{
            margin-right: 10px;
        }
        .xinjian{
            text-align: center;line-height: 28px;height: 28px;width: 70px;
        }
        .bordercolor input:disabled,.bordercolor select:disabled{background: #fcfcfc !important;}
    </style>
    <link rel="stylesheet" href="/css/biaodan.css">
</head>
<body>
<div style="    height: 45px;border-bottom: 1px solid #dddddd;">
    <div class="headImg" style="width: 23px;height: 23px;margin-left: 2%;">
        <img style="    margin-top: 10px;width: 100%;height: 100%" src="/img/document/icon_agentDispatch.png" alt="">
    </div>
    <div class="divTitle" style="font-size: 22px;margin-left: 60px;line-height: 0;">
        布控点位
    </div>
</div>
<div class="content" style="padding-top:14px;">
    <div class="tableList" >
        <div class="headNav">
            <button id="inport">导入</button>
            <span style=" margin-left:20px;">所属社区</span>
            <select name="" id="queryGridId"></select>
            <span>布控级别</span>
            <select name="" id="queryControlLevel"></select>
            <button id="query">查询</button>
            <button class="choose" id="add" data-type="0">新建</button>
        </div>
        <div class="table">
            <table>
                <thead>
                <tr>
                    <th>序号</th>
                    <th class="th">所属社区</th>
                    <th class="th">布控级别</th>
                    <th class="th">点位数</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody class="list" id="tableList">

                </tbody>
            </table>

            <div style="margin: 0px auto 0px;height:50px;width: 97%;" class="clearfix">
                <div id="dbgz_page" class="M-box3" style="display: none">

                </div>
            </div>
        </div>
    </div>
    <div class="mainBg" style="background: #fff;display: none">
        <form action="" id="datasave">

            <div class="mainTitle">
                <ul class="mainTitleUl">
                    <li style="    padding-top: 18px;text-align: center;height: 61px;border-bottom: 1px solid #ddd">
                        <span class="spanSize">布控点位信息</span>
                    </li>

                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;">所属社区<b style="color: red;">*</b></span>
                        <label style="width: 80%;">
                            <select name="gridInfo" id="gridId" style="width:92%">
                            </select>
                        </label>
                    </li>

                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;">布控级别<b style="color: red;">*</b></span>
                        <label style="width: 80%;">
                            <select name="dispa" id="dispatchedStatc" style="width:92%"></select>
                        </label>
                    </li>

                    <li class="bordercolor clearfix">
                        <span style="border-bottom: 1px solid #fff;">点位数<b style="color: red;">*</b></span>
                        <label style="width: 80%;">
                            <input readonly="readonly" id="dianrens" name="id" name="dianwenrens" value="" placeholder="请在操作中添加点位数" type="text" style="background: -webkit-linear-gradient(top, #fffbf6, #fdf1e0);border-radius: 6px;width: 500px">
                        </label>
                    </li>
                    <div class="table" style="margin: 0;width: 593px;margin-left: 133px;" id="dianweicha">
                        <table>
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th class="th">点位名称</th>
                                <th class="th">点位位置</th>
                                <th class="th">点位人数</th>

                            </tr>
                            </thead>
                            <tbody class="" id="dianweinum2">

                            </tbody>
                        </table>
                    </div>


                </ul>
                <div style="height: 88px;line-height: 88px;text-align: center">
                    <a href="javascript:void (0)" class="preservation" style="
                margin-top: 25px;display: inline-block;margin-right: 10px;
                line-height: 1;font-size:18px;padding: 8px 20px;
                background: #2F8AE3;color: #fff;border-radius: 6px">保存</a>
                    <a href="javascript:void (0)" class="getBack"  style="
                margin-top: 25px;display: inline-block;
                line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px">返回</a>
                </div>
            </div>
        </form>
    </div>
</div>



<script>

//    function setZuobiao(str){
//        $('input[name="gridLocation"]').val(str)
//    }
    function check(name){
        if(name == undefined){
            return ''
        }else{
            return name;
        }
    }
    var str1="<option value=\"\" selected=\"\">请选择</option>";
    var str2="<option value=\"\" selected=\"\">请选择</option>";

    //    点击返回
    $('.getBack').click(function(){
        $('.tableList').show();
        $('.mainBg').hide();
    })
    //    点击坐标定位
    $('.dwbtn').click(function () {
        window.open('/street/chooseMap')
    })
    //    设置坐标
    function setZuobiao(str){
        $('input[name="addressLocation"]').val(str)
    }
    //    禁用
    function noUser(){
        $('.mainBg input[type="text"]').attr('disabled','disabled');
        $('.mainBg input[type="radio"]').attr('disabled','disabled');
        $('textarea').attr('disabled','disabled');
        //$('#gridId').css("disabled","disabled");
        $("#gridId").attr("disabled",true);
        $("#dispatchedStatc").attr("disabled",true);
    }
    //    可以使用
    function use(){
        $('input[type="text"]').removeAttr('disabled');
        $('input[type="radio"]').removeAttr('disabled');
        $('textarea').removeAttr('disabled');
        $("#gridId").attr("disabled",false);
        $("#dispatchedStatc").attr("disabled",false);
    }

    //    获取所属社区下拉框内容
    $.get('/executeControl/getAllGridInfo?parentNo=TYPE_OF_ACCOUNT',function (json) {
       // console.log(json.obj[i])
        //if(json.flag){
            var str='<option value="">请选择</option>';
            var str1='<option value="">请选择</option>';
            for(var i=0;i<json.obj.length;i++){
                //console.log(json.obj[i])
                str+='<option value="'+json.obj[i].codeNo+'">'+json.obj[i].codeName+'</option>'
                str1+='<option value="'+json.obj[i].codeNo+'">'+json.obj[i].codeName+'</option>'
            }
        $('#gridId').html(str);
        $('#queryGridId').html(str1)
        //}
    })

    //    获取布控级别下拉框内容
    $.ajax({
        url: "/executeControl/getAllGridInfo?parentNo=org_dispa",
        type:'get',
        success:function(data){
            var datas=data.obj;
            var str='<option value="">请选择</option>';
            var str1='<option value="">请选择</option>';
            for(var i=0;i<datas.length;i++){
                //console.log(datas)
                str+='<option value="'+datas[i].codeNo+'">'+datas[i].codeName+'</option>'
                str1+='<option value="'+datas[i].codeNo+'">'+datas[i].codeName+'</option>'
            }
            $('#dispatchedStatc').append(str);
            $('#queryControlLevel').append(str1)
        }
    })

    //    分页列表
    var ajaxPageLe={
        data:{
            page:1,//当前处于第几页
            pageSize:10,//一页显示几条
        },
        page:function () {
            var me=this;
            $.ajax({
                url:'/executeControl/getAllExecute',
                type:'get',
                data:me.data,
                dataType:'json',
                success:function(reg){
                    var datas=reg.obj;
                    var str="";
                    for(var i=0;i<datas.length;i++){
                        //console.log(datas)
                        str+=' <tr id="'+datas[i].conId+'">'+
                            '<td>'+(i+1)+'</td>'+
                            '<td>'+datas[i].gridName+'</td>'+
                            '<td>'+datas[i].dispaName+'</td>' +
                            ' <td>'+function () {
                                if(datas[i].point == undefined){
                                    return ''
                                }else{
                                    return datas[i].point
                                }
                            }() +'</td>' +
                            ' <td>' +
                            ' <a href="javascript:;" class="choose" data-type="1">查看</a>' +
                            ' <a href="javascript:;" class="choose" data-type="2">修改</a>' +
                            ' <a href="javascript:;" class=" xinjian" >添加点位数</a>' +
                            ' <a href="javascript:;" class="del">删除</a>' +
                            ' </td>' +
                            '</tr>'
                    }
                    $('.list').html(str);
                    if(reg.totleNum>10){
                        $('#dbgz_page').show();
                        me.pageTwo(reg.totleNum,me.data.pageSize,me.data.page)
                    } else {
                        $('#dbgz_page').hide();
                    }
                    tianjiadianwei()
                }

            });
        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }
    ajaxPageLe.page();
    //    点击全选
    $('#checkAll').click(function(){
        var state=$(this).prop('checked');
        if(state == true){
            $(this).prop('checked',true);
            $('.childCheck').prop('checked',true);
        }else{
            $(this).prop('checked',false);
            $('.childCheck').prop('checked',false);
        }
    })
    $(document).on('click','.choose',function(){
        var type=$(this).attr('data-type');
        $('.tableList').hide();
        $('.mainBg').show();
        if(type==0){//新建
            $('#jiandianbiao').hide();
            $('#jiandianwei').hide();
            $('.preservation').attr('data-type','0');
            $('.preservation').show();
            $('#dianweicha').hide();
            use();
            refresh()
            $('#datasave').attr('action','/executeControl/addExecute')
        }else if(type==1){//查看
            $('#jiandianbiao').show();
            $('#jiandianwei').show();
            var id=$(this).parents('tr').attr('id');

            $('.preservation').hide();
            noUser();
            detail(id);
            dianwei2(id)
            $('#dianweicha').show();
        }else{//修改
            $('#jiandianbiao').show();
            $('#jiandianwei').show();
            var id=$(this).parents('tr').attr('id');
            $('.preservation').attr('data-type','2');
            $('.preservation').show();
            $('#datasave').attr('action','/executeControl/updateExecuteById?conId='+id)
            use();
            detail(id);
            $('#dianweicha').hide();
        }
    })
    //    点击删除
    $('.list').on('click','.del',function(){
        var id=$(this).parents('tr').attr('id');
        layer.confirm(' 确定要删除吗', {
            btn: ['确定', '取消'], //按钮
            title: " 删除"
        },function(){
            $.ajax({
                url:'/executeControl/delExecute',
                type:'post',
                dataType:'json',
                data:{conId:id},
                success:function(){
                    layer.msg(' 删除成功', {icon: 6});
                    ajaxPageLe.page();
                }
            })
        }, function () {
            layer.closeAll();
        })
    })

    //    点击保存
    $('.preservation').click(function(){
        var type=$(this).attr('data-type');
        $('input[name="deptName"]').val($('#grid option:selected').text())
        if($('#gridId').val()==""){
            $.layerMsg({content:'请选择所属社区',icon:6})
            return;
        }
        if($('#dispatchedStatc').val()==""){
            $.layerMsg({content:'请选取布控级别',icon:6})
            return;
        }

        if($('input[name="dianwenrens"]').val()==""){
            $.layerMsg({content:'请填写点位人数',icon:6})
            return;
        }

        if(type==0){//新建
            $('#datasave').ajaxSubmit({
                type:'post',
                dataType:'json',
                success:function(res){
                    if(res.flag){
                        //console.log($('#dianrens').val())
                        //console.log($('#dispatchedStatc').val())
                        //console.log($('#gridId').val())
                        $.layerMsg({content:'新建成功',icon:1})
                        $('.tableList').show();
                        $('.mainBg').hide();
                        ajaxPageLe.data.page=1;
                        ajaxPageLe.page();
                    }else{
                        $.layerMsg({content:'新建失败',icon:1})
                    }
                }
            })
        }else if(type==2){//修改
            $('#datasave').ajaxSubmit({
                type:'post',
                dataType:'json',
                success:function(res){
                    if(res.flag){
                        $.layerMsg({content:'修改成功',icon:1})
                        $('.tableList').show();
                        $('.mainBg').hide();
                        ajaxPageLe.data.page=1;
                        ajaxPageLe.page();
                    }else{
                        $.layerMsg({content:'修改失败',icon:1})
                    }
                }
            })
        }
    })

    //    查看详情
    function  detail(id) {
        $.ajax({
            url:'/executeControl/getExecuteById',
            data:{conId:id},
            dataType:'json',
            type:'get',
            success:function(res){
                var data=res.object;
                //.log(data)
                //console.log(data.gridInfo)
                //$("#gridId").val("公共区域");
                //console.log(data.dispa)
                $('#gridId').val(data.gridInfo);//所属社区
                $('#dispatchedStatc').val(data.dispa);//布控级别
                $('#dianrens').val(data.point);//点位人数

                $('#dianweibiaos').val(data.pointCoordinate);//点位坐标
                $('#dianwenzhis').val(data.pointPlace);//点位位置
            }
        })
        //点位坐标和点位位置的查看


    }

    //    ridio check
    function check(name,data){
        $(':radio[name="'+name+'"][value="'+data+'"]').prop('checked','check')

    }
    //    点击查询
    $('#query').click(function(){
        ajaxPageLe.data.gridId=$("#queryGridId option:selected").val();
        ajaxPageLe.data.dispa=$("#queryControlLevel option:selected").val();
        ajaxPageLe.page();
    })

    //    点击导入
    $('#inport').click(function(){
        layer.open({
            type:1,
            title: ['布控点位导入', 'background-color:#2b7fe0;color:#fff;'],
            area: ['600px', '420px'],
            btn: ['导入', '取消'],
            content:'<div>' +
            '<form class="form1" name="form1" id="uploadForm" method="post" action="/OrgPartyMember/ecoudInsert" enctype="multipart/form-data">' +
            '<table class="importTable"> ' +
            '<tr><td style="width: 100px;">下载导入模板：</td><td style="text-align: left;"><a id="model" style="cursor:pointer">布控点位模板下载</a></td></tr>' +
            '<tr> <td>选择导入文件：</td> <td><input style="width: auto" type="file" name="file"/></td> </tr>' +
            '<tr>' +
            '<td>说明：</td>'+
            '<td style="text-align: left;"><p>1、请导入.xls文件或者.xlsx。</p>'+
//            '<p>2、请填写网格信息中已有网格。</p>'+
            ' </td> ' +
            '</tr>' +
            '</table>' +
            '</form>' +
            '</div>',
            success:function(){
                $('#model').click(function () {
                    window.location.href = encodeURI("/file/grid/布控点位模板.xls");
                });
            },
            yes:function(obj){
                var flag = CheckForm();
                if (flag) {
                    layer.msg("正在导入中，请耐心等候", {icon: 1});
                    $.upload($('#uploadForm'), function (res) {
                        if(res.flag) {
                            layer.msg("导入成功", {icon: 1});
                        }else{
                            layer.msg("导入失败", {icon: 2});
                        }
                    });

                    location.reload()
                }
            }
        })
    })
    function CheckForm(){
        if(document.form1.file.value==""){
            layer.msg("请导入至少一条数据！",{icon:2});
            return (false);
        }
        return (true);
    }

    //    点击导出
    $('#outport').click(function(){
        window.location.href= '<%=basePath%>esCommittee/outPutFile';
        <%--if($('.childCheck:checked').length<=0){--%>
         <%--$.layerMsg({content:'请选择至少一条数据',icon:6})--%>
         <%--}else{--%>
         <%--var arr=[]--%>
         <%--$('.childCheck:checked').each(function(){--%>
         <%--var id=$(this).parents('tr').attr('id');--%>
         <%--arr.push(id)--%>
         <%--})--%>
                    <%--var str=arr.join()--%>
                    <%--console.log(str)--%>
         <%--window.location.href= '<%=basePath%>enCaterParameter/queryList?manyId='+arr+'&export=1';--%>
         <%--}--%>

    })

    //    重置
    function refresh(){
        $('#gridId').val('')
        $('input[name="dispatchedStatc"]').val('');//灶头数
        $('input[name="idsum"]').val('');//所属社区
        $('input[name="address"]').val('')//垃圾桶总数
        $('input[name="addressLocation"]').val('');//架子总数
        $('input[name="countsum"]').val('');//绿桶总数
        $('#dispatchedStatc').val('')
    }
    function tianjiadianwei() {
        //添加点位数
        $('.xinjian').click(function () {
            layer.open({
                type: 1,
                scrollbar: false,
                area:['700px','535px'],
                btn:0,
                title: '添加点位数',
                content:  '<div><div  style="height: 45px;border-bottom: 1px solid #dddddd;">' +
                ' <div class="headImg" style="width: 23px;height: 23px;margin-left: 2%;">' +
                '<img style="margin-top: 10px;width: 100%;height: 100%" src="/img/document/icon_agentDispatch.png" alt="">' +
                ' </div>' +
                ' <div class="divTitle" style="font-size: 22px;margin-left: 60px;line-height: 0;">布控点位 </div>' +
                '<input class="tianjia " data-type="1"  style="cursor: pointer;width:66px;position:absolute;top:12px;right:15px;background:#2F8AE3;text-align:center;height:26px;color:#fff !important;border:none;border-radius:5px;" readonly="readonly" value="添加" name="">' +
                '</div>' +

                '<div class="table"><table> <thead>'+

                '<tr><th>序号</th><th class="th">点位名称</th><th class="th">点位位置</th><th class="th">点位人数</th><th>操作</th></tr>'+
                ' </thead>'+
                ' <tbody class="list" id="dianweinum">'+

                ' </tbody></table> </div>' +
                '<div style="height: 88px;line-height: 88px;text-align: center">' +
                '<a href="javascript:;" class="preservation quedinga" style="' +
                'margin-top: 25px;display: inline-block;margin-right: 10px;' +
                'line-height: 1;font-size:18px;padding: 8px 20px;' +
                'background: #2F8AE3;color: #fff;border-radius: 6px;float:right;margin-right:15px !important;" >确定</a>' +

                '</div>' +
                ' <div class="tianjiaBox" style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;background: #fff;display: none;">  ' +

                //这里是添加点位数
                '<div style="    height: 45px;border-bottom: 1px solid #dddddd;">' +

                ' <div class="headImg" style="width: 23px;height: 23px;margin-left: 2%;">' +
                '<img style="    margin-top: 10px;width: 100%;height: 100%" src="/img/document/icon_agentDispatch.png" alt="">' +
                ' </div>' +
                ' <div class="divTitle" style="font-size: 22px;margin-left: 60px;line-height: 0;"> 布控点位 </div>' +

                '</div>' +
                '<div class=""><ul class="mainTitleUl" style="margin-top:46px;">' +

                '<li class="bordercolor clearfix" style="padding-left: 0">' +
                ' <span style="">点位名称</span>' +
                ' <label style="width: 80%;">' +
                '<input id="diannameids" type="text" name="pointPlace" placeholder="请填写点位名称" style="background: #fcfcfc;    width: 92%;' +
                'float: none;' +
                ' margin-top: 9px;">' +
                '</label>' +
                '</li>' +

                '<li class="bordercolor clearfix" style="padding-left: 0">' +
                ' <span style="">点位位置</span>' +
                ' <label style="width: 80%;">' +
                '<input id="dianweiids" type="text" name="pointPlace" placeholder="请填写点位位置" style="background: #fcfcfc;    width: 92%;' +
                'float: none;' +
                ' margin-top: 9px;">' +
                '</label>' +
                '</li>' +
                '<li class="bordercolor clearfix" style="padding-left: 0">' +
                '<span style="">点位坐标<b style="color: red;">*</b></span>' +
                ' <label style="width: 80%;position:relative">' +
                '<input id="dianbiaoid" type="text" name="addressLocation" style="margin-left:4%;width:92%" readonly="readonly">' +
                '<button type="button" class="dwbtn" style="position: absolute;width: 82px;height: 39px; background-color: #228cdc;color: #fff; right: 13px;top:9px;border-radius: 3px;cursor: pointer;">点击定位</button>' +
                '</label>' +
                '</li>' +
                '<li class="bordercolor clearfix" style="padding-left: 0">' +
                ' <span style="border-bottom: 1px solid #fff;">点位人数</span>' +
                ' <label style="width: 80%;">' +
                '<input id="dianrenid" type="text" name="pointPeo" placeholder="请填写点位人数" style="background: #fcfcfc;    width: 92%;' +
                'float: none;' +
                ' margin-top: 9px;">' +
                '</label>' +
                '</li>' +


                '</ul>' +
                '<div style="height: 88px;line-height: 88px;text-align: center">' +
                '<a href="javascript:;" id="tijiaoid" class="preservation baocun" style="' +
                'margin-top: 25px;display: inline-block;margin-right: 10px;' +
                'line-height: 1;font-size:18px;padding: 8px 20px;' +
                'background: #2F8AE3;color: #fff;border-radius: 6px" >保存</a>' +
                '<a href="javascript:;" class="getBack fanhui" style="' +
                'margin-top: 25px;display: inline-block;' +
                'line-height: 1;font-size:18px;padding: 8px 20px;background: #2F8AE3;color: #fff;border-radius: 6px" >返回</a>' +
                '</div>' +
                '</div> '+
                //添加点位数结束
                '</div>' +
                '</div>'
            });




           // function tiandianwei() {
                $(".tianjia").click(function () {
                    var type=$(this).attr('data-type');

                        $('#tijiaoid').click(function () {
                            //alert($(".tianjia").attr("name"))对应的布控点位的i
                            if ($('#diannameids').val()=='') {
                                $.layerMsg({content:'请填写点位名称',icon:6});
                                return false;
                            }
                            if ($('#dianweiids').val()=='') {//点位位置
                                $.layerMsg({content:'请填写点位位置',icon:6});
                                return false;
                            }
                            if ($('#dianbiaoid').val()=='') {//点位坐标
                                $.layerMsg({content:'请选择点位坐标',icon:6});
                                return false;
                            }
                            if ($('#dianrenid').val()=='') {//点位人数
                                $.layerMsg({content:'请填写点位人数',icon:6});
                                return false;
                            }
                            $.ajax({
                                url: "/point/addExecute",
                                type: 'post',
                                dataType: 'json',
                                data: {
                                    'eId': $(".tianjia").attr("name"),
                                    'pointName': $('#diannameids').val(),//名称
                                    'pointCoordinate':$('#dianbiaoid').val(),//坐标
                                    'pointPlace': $('#dianweiids').val(),//位置
                                    'pointPeo': $('#dianrenid').val()//人数
                                },
                                success: function(data) {
                                    $.layerMsg({content:'添加成功',icon:6});
                                    $('.tianjiaBox').hide()
                                    dianwei(id)
                                },
                                error: function(XMLHttpRequest, textStatus, errorThrown) {
                                    $.layerMsg({content:'添加失败',icon:6});
                                }
                            });
                            return true;
                        })
                });

            //}
            //查询数据
            var id=$(this).parents('tr').attr('id');
            //alert(id)
            dianwei(id)

            //修改
            $('.dwbtn').click(function () {
//                window.open('/street/chooseMap')
                window.open('/street/mapCoordinates?type=4')
            })

            //添加
            //$('.tianjia').
            $('.tianjia').click(function () {
                $('.tianjiaBox').show();
            })
            //返回
            $('.fanhui').click(function ()  {
                $('.tianjiaBox').hide()
            })

            //确定
            $('.quedinga').click(function () {
                layer.closeAll();
                var dianweimu=$('#dianweinum').children('tr').length;
                $('#dianshus').val(dianweimu)
            })
        })
    }
    function dianwei(id) {//点位数的查询
       $(".tianjia").attr("name",id);
        //console.log(id)
        $.ajax({
            url:'/point/getPointByConId',
            type:'get',
            data:{conId:id},
            dataType:'json',
            success:function(reg){
                var datas=reg.obj;
                console.log(datas)
                var strs="";
                for(var i=0;i<datas.length;i++){
                    strs+= ' <tr id="'+datas[i].ponitId+'">'
                    strs+=' <td>'+(i+1)+'</td><td>'+datas[i].pointName+'</td><td>'+datas[i].pointPlace+'</td><td>'+datas[i].pointPeo+'</td>'
                    strs+=' <td><button class="xiugais tianjia2" data-type="2" style="display: inline-block;cursor: pointer;border: none;background: none;width: 52px;color: #333">修改</button><a href="javascript:;" class="shandiansid">删除</a></td>'
                    strs+='</tr>'
                }
                $('#dianweinum').html(strs);
                $(".tianjia2").click(function () {//修改
                    var idd=$(this).parents('tr').attr('id')
                    $.ajax({
                        type:'get',
                        url:"/point/selectByPrimaryKey",
                        data:{ponitId:idd},
                        dataType:'json',
                        success:function(data){
                            var data=data.object;
                            //console.log(data)
                            $('#diannameids').val(data.pointName);//点位名
                            $('#dianweiids').val(data.pointPlace);//点位位置
                            $('#dianbiaoid').val(data.pointCoordinate);//点位坐标
                            $('#dianrenid').val(data.pointPeo);//点位人数
                        },
                    });


                    $('.tianjiaBox').show();
                    $('#tijiaoid').click(function () {
                        if ($('#diannameids').val()=='') {
                            $.layerMsg({content:'请填写点位名称',icon:6});
                            return false;
                        }
                        if ($('#dianweiids').val()=='') {//点位位置
                            $.layerMsg({content:'请填写点位位置',icon:6});
                            return false;
                        }
                        if ($('#dianbiaoid').val()=='') {//点位坐标
                            $.layerMsg({content:'请选择点位坐标',icon:6});
                            return false;
                        }
                        if ($('#dianrenid').val()=='') {//点位人数
                            $.layerMsg({content:'请填写点位人数',icon:6});
                            return false;
                        }
                        $.ajax({
                            url: "/point/updateExecuteById",
                            type: 'post',
                            dataType: 'json',
                            data: {
                                'ponitId': idd,
                                'eId': $(".tianjia").attr("name"),
                                'pointName': $('#diannameids').val(),//名称
                                'pointCoordinate':$('#dianbiaoid').val(),//坐标
                                'pointPlace': $('#dianweiids').val(),//位置
                                'pointPeo': $('#dianrenid').val()//人数
                            },
                            success: function(data) {
                                $.layerMsg({content:'修改成功',icon:6});
                                $('.tianjiaBox').hide()
                                dianwei(id)
                            },
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                $.layerMsg({content:'修改失败',icon:6});
                            }
                        });
                        return true;
                    })

                });


                $('.list').on('click','.shandiansid',function(){//删除点位
                    var id=$(this).parents('tr').attr('id');
                    layer.confirm(' 确定要删除吗', {
                        btn: ['确定', '取消'], //按钮
                        title: " 删除"
                    },function(){
                        $.ajax({
                            url:'/point/delExecute',
                            type:'post',
                            dataType:'json',
                            data:{pId:id},
                            success:function(){
                                layer.msg(' 删除成功', {icon: 6});
                               var id=$(".tianjia").attr("name");
                                dianwei(id)
                            }
                        })
                    }, function () {
                        layer.closeAll();
                    })
                })
            }
        })


        //删除点位

    }

    function dianwei2(id) {//点位数的查询
        $.ajax({
            url:'/point/getPointByConId',
            type:'get',
            data:{conId:id},
            dataType:'json',
            success:function(reg){
                var datas=reg.obj;
                //console.log(datas)
                var strs="";
                for(var i=0;i<datas.length;i++){
                    strs+= ' <tr id="'+datas[i].ponitId+'">'
                    strs+=' <td>'+(i+1)+'</td><td>我是点位名称</td><td>'+datas[i].pointPlace+'</td><td>'+datas[i].pointPeo+'</td>'
                    strs+='</tr>'
                }
                $('#dianweinum2').html(strs);
            }
        })
    }
</script>
</body>
</html>

